package com.rocksdata.mc.ui.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.ctz.commonframe.constant.DeviceInfo;
import com.ctz.commonframe.utils.GlideApp;
import com.rocksdata.mc.R;
import com.rocksdata.mc.entity.NewsInfo2;


/**
 * Created by 陈堂正 on 2017/5/12.
 */

public class NewsSingleBigImageHolder extends AbsNewsHolder<NewsInfo2> {
    private TextView tvTitle;
    private TextView tvOtherInfo;
    private ImageView ivImage;

    NewsSingleBigImageHolder(View itemView) {
        super(itemView);
        tvTitle = itemView.findViewById(R.id.tv_news_title);
        tvOtherInfo = itemView.findViewById(R.id.tv_news_other_info);
        ivImage = itemView.findViewById(R.id.iv_news_image);

        ViewGroup.LayoutParams imageParams = ivImage.getLayoutParams();
        imageParams.height = (DeviceInfo.screenWidth - 32) * 9 / 16 ;
        ivImage.setLayoutParams(imageParams);
    }

    @Override
    public void bindData(NewsInfo2 info) {
        tvTitle.setText(info.getTitle());
        tvOtherInfo.setText(info.getDepartmentName() + "  " + info.getCommentCount() + "评论  " + info.getPublishedTime());
//        if(Config.isDebug){
//            ivImage.setImageResource(info.getImageList().get(0).getRes());
//        }else{
//            XUtils3ImageDisplayer.display(ivImage, info.getImageList().get(0).getImageUrl());
//        }
        GlideApp.with(ivImage.getContext()).load(info.getImgURL().get(0)).centerCrop().into(ivImage);
    }
}
